import { defHttp } from '@/utils/http/axios';
import {
  GetMenuTreeListRes,
  CreateMenuReq,
  CreateMenuActionReq,
  UpdateMenuReq,
  UpdateMenuActionReq,
} from './model/menuModel';

enum Api {
  Menu = '/system/menu',
  MenuTreeList = '/system/menu/tree',
  MenuAction = '/system/menu/action',
  MenuWithId = '/system/menu/{menu_id}',
}

//menu
export const apiGetMenuTreeList = () =>
  defHttp.get<GetMenuTreeListRes>({
    url: Api.MenuTreeList,
  });

export const apiCreateMenu = (params: CreateMenuReq) =>
  defHttp.post({ url: Api.Menu, params: params });

export const apiCreateMenuAction = (params: CreateMenuActionReq) =>
  defHttp.post({ url: Api.MenuAction, params: params });

export const apiUpdateMenu = (params: UpdateMenuReq) =>
  defHttp.put({ url: Api.Menu, params: params });

export const apiUpdateMenuAction = (params: UpdateMenuActionReq) =>
  defHttp.put({ url: Api.MenuAction, params: params });

export const apiDeleteMenu = (menuId: number) =>
  defHttp.delete({ url: Api.MenuWithId.replace('{menu_id}', menuId.toString()) });

// export const detailMenu = (menuId: number) =>
//   defHttp.get({ url: Api.MenuWithId.replace('{menu_id}', menuId.toString()) });
